package com.platform.enums;


import com.google.common.collect.Lists;
import com.platform.comm.constants.EnumOption;
import com.platform.comm.enums.IDictEntry;
import com.platform.comm.enums.IEnumItem;
import com.platform.comm.enums.IEnumOption;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zq
 */
@EnumOption(name = "dbpBatchRepairStatus")
public enum DbpBatchRepairStatus implements IDictEntry, IEnumItem, IEnumOption<String> {
    /**
     * 已修复
     */
    repaired("repaired", "已修复"),

    /**
     * 未修复
     */
    no_repaired("no_repaired", "未修复");

    public final String code;
    public final String title;

    DbpBatchRepairStatus(String code, String title) {
        this.code = code;
        this.title = title;
    }

    /**
     * 根据枚举"键"值解析枚举值
     *
     * @param code 枚举"键"值
     * @return DirFieldStatus
     */
    public static DbpBatchRepairStatus parse(String code) {
        return Lists.newArrayList(values())
                .stream()
                .filter(item -> item.is(code))
                .findFirst().orElse(null);
    }

    @Override
    public boolean is(String code) {
        return this.code.equals(code);
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return title;
    }

    @Override
    public Object getData() {
        return this;
    }


    @Override
    public String key() {
        return code;
    }

    @Override
    public String value() {
        return title;
    }

    @Override
    public Map<String, String> enums() {
        return Arrays.stream(values()).collect(Collectors.toMap(IEnumOption::key, IEnumOption::value));
    }
}
